"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Logger = void 0;
const LogFileUtil_1 = require("./LogFileUtil");
const Log_Level_Names = ["debug", "log", "info", "warn", "error"];
class Logger {
    static formatNow() {
        let date = new Date(); //后端返回的时间戳是秒
        return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds() + ":" + date.getMilliseconds();
    }
    static getLogPreKey(nowLevel) {
        let str = "[" + Logger.formatNow() + "] " + Logger.tag + " ["
            + Log_Level_Names[nowLevel] + "] ";
        return str;
    }
    static debug(...params) {
        if (Logger.LEVEL > Logger.LOG_LEVEL_TYPES.DEBUG) {
            return;
        }
        let str = this.getLogPreKey(Logger.LOG_LEVEL_TYPES.DEBUG);
        let fileStr = str + params.join(" ");
        LogFileUtil_1.LogFileUtil.debug(fileStr);
        if (this.Terminal_Log) {
            return console.debug("%c" + str, this.Log_Color_Config[Logger.LOG_LEVEL_TYPES.DEBUG], ...params);
        }
        else {
            return console.debug(str, ...params);
        }
    }
    static log(...params) {
        if (Logger.LEVEL > Logger.LOG_LEVEL_TYPES.LOG) {
            return;
        }
        let str = this.getLogPreKey(Logger.LOG_LEVEL_TYPES.LOG);
        let fileStr = str + params.join(" ");
        LogFileUtil_1.LogFileUtil.log(fileStr);
        if (this.Terminal_Log) {
            return console.log("%c" + str, this.Log_Color_Config[Logger.LOG_LEVEL_TYPES.DEBUG], ...params);
        }
        else {
            return console.log(str, ...params);
        }
    }
    static info(...params) {
        if (Logger.LEVEL > Logger.LOG_LEVEL_TYPES.INFO) {
            return;
        }
        let str = this.getLogPreKey(Logger.LOG_LEVEL_TYPES.INFO);
        let fileStr = str + params.join(" ");
        LogFileUtil_1.LogFileUtil.info(fileStr);
        if (this.Terminal_Log) {
            return console.info("%c" + str, this.Log_Color_Config[Logger.LOG_LEVEL_TYPES.DEBUG], ...params);
        }
        else {
            return console.info(str, ...params);
        }
    }
    static warn(...params) {
        if (Logger.LEVEL > Logger.LOG_LEVEL_TYPES.WARN) {
            return;
        }
        let str = this.getLogPreKey(Logger.LOG_LEVEL_TYPES.WARN);
        let fileStr = str + params.join(" ");
        LogFileUtil_1.LogFileUtil.warn(fileStr);
        if (this.Terminal_Log) {
            return console.warn("%c" + str, this.Log_Color_Config[Logger.LOG_LEVEL_TYPES.DEBUG], ...params);
        }
        else {
            return console.warn(str, ...params);
        }
    }
    static error(...params) {
        if (Logger.LEVEL > Logger.LOG_LEVEL_TYPES.ERROR) {
            return;
        }
        let str = this.getLogPreKey(Logger.LOG_LEVEL_TYPES.ERROR);
        let fileStr = str + params.join(" ");
        LogFileUtil_1.LogFileUtil.error(fileStr);
        if (this.Terminal_Log) {
            console.error("%c" + str, this.Log_Color_Config[Logger.LOG_LEVEL_TYPES.DEBUG], ...params);
        }
        else {
            console.error(str, ...params);
        }
    }
}
exports.Logger = Logger;
Logger.LOG_LEVEL_TYPES = {
    DEBUG: 0,
    LOG: 1,
    INFO: 2,
    WARN: 3,
    ERROR: 4
};
Logger.tag = "[HaoJslog]"; //可以设置当前游戏的前缀
Logger.LEVEL = Logger.LOG_LEVEL_TYPES.LOG; //当前Logger等级
Logger.Log_Color_Config = [
    "color:#290;font-size:20px;",
    "color:#000;font-size:21px;",
    "color:#09f;font-size:22px;",
    "color:#f90;font-size:23px;",
    "color:#f00;font-size:23px;",
];
Logger.Terminal_Log = false;
